/**
 * ! 筛选{param}参数
 */
export function sift_query_list(query) {
	const query_ = {};
	for (const param in query) {
		if (['', null, undefined].indexOf(query[param]) !== -1) continue;
		query_[param] = query[param];
	}

	return query_;
}
/**
 * ! 权限处理工具
 */
export function hasPermission(permissions, route) {
	if (route.name) {
		for (let permission of permissions) {
			if (permission.label === route.name) return true;
			if (permission.children) {
				for (let submenu of permission.children) {
					if (submenu.label === route.name) return true;
				}
			}
		}
		return false;
	} else {
		return true;
	}
}
// 合并数组中相同的key
export function dealWithData(data) {
	let c = [];
	let d = {};
	data.forEach((element, index) => {
		if (!d[element.pName]) {
			c.push({
				text: element.pName,
				allData: [element],
				id: (index + 1)
			});
			d[element.pName] = element;
		} else {
			c.forEach(ele => {
				if (ele.text == element.pName) {
					ele.allData.push(element);
				}
			});
		}

	});
	return c;
}
// 对比数组
export function filterArr(result, ids) {
	let resultArr = []
	result.filter(item => {
		ids.some((_item => {
			if (item.id == _item) {
				resultArr.push(item)
			}
		}))
	})
	return resultArr
}
